package Gantry::Samples::User;

use strict;

use base 'Gantry::Samples::GEN::User';

use Gantry::Plugins::AutoCRUD qw(
    do_add
    do_edit
    do_delete
    form_name
    write_file
);

use Gantry::Samples::Model::user qw(
    $USER
);
use Gantry::Samples::Model;
sub schema_base_class { return 'Gantry::Samples::Model'; }
use Gantry::Plugins::DBIxClassConn qw( get_schema );
use Gantry::Utils::Threeway;

#-----------------------------------------------------------------
# $self->do_groups(  )
#-----------------------------------------------------------------
sub do_groups {
    my ( $self, $user_id ) = @_;
    
    my $threeway = Gantry::Utils::Threeway->new( { 
        self            => $self,
        primary_id      => $user_id,
        primary_table   => 'user',
        join_table      => 'user_user_group',
        secondary_table => 'user_group',
        legend          => 'Assign Groups to User'        
    } );

    $threeway->process();
    
} # END do_groups

#-----------------------------------------------------------------
# $self->do_main(  )
#-----------------------------------------------------------------
# This method inherited from Gantry::Samples::GEN::User

#-----------------------------------------------------------------
# $self->form( $row )
#-----------------------------------------------------------------
# This method inherited from Gantry::Samples::GEN::User


#-----------------------------------------------------------------
# get_model_name( )
#-----------------------------------------------------------------
sub get_model_name {
    return $USER;
}

#-----------------------------------------------------------------
# get_orm_helper( )
#-----------------------------------------------------------------
sub get_orm_helper {
    return 'Gantry::Plugins::AutoCRUDHelper::DBIxClass';
}

#-----------------------------------------------------------------
# text_descr( )
#-----------------------------------------------------------------
sub text_descr     {
    return 'user';
}

1;

=head1 NAME

Gantry::Samples::User - A controller in the Gantry::Samples application

=head1 SYNOPSIS

This package is meant to be used in a stand alone server/CGI script or the
Perl block of an httpd.conf file.

Stand Alone Server or CGI script:

    use Gantry::Samples::User;

    my $cgi = Gantry::Engine::CGI->new( {
        config => {
            #...
        },
        locations => {
            '/someurl' => 'Gantry::Samples::User',
            #...
        },
    } );

httpd.conf:

    <Perl>
        # ...
        use Gantry::Samples::User;
    </Perl>

    <Location /someurl>
        SetHandler  perl-script
        PerlHandler Gantry::Samples::User
    </Location>

If all went well, one of these was correctly written during app generation.

=head1 DESCRIPTION

This module was originally generated by Bigtop.  But feel free to edit it.
You might even want to describe the table this module controls here.

=head1 METHODS

=over 4

=item do_groups

=item get_model_name

=item text_descr

=item schema_base_class

=item get_orm_helper


=back


=head1 METHODS INHERITED FROM Gantry::Samples::GEN::User

=over 4

=item controller_config

=item do_main

=item form


=back


=head1 DEPENDENCIES

    Gantry::Samples
    Gantry::Samples::GEN::User
    Gantry::Samples::Model::user
    Gantry::Plugins::AutoCRUD

=head1 AUTHOR

Timotheus Keefer, E<lt>tkeefer@apple.comE<gt>

=head1 COPYRIGHT AND LICENSE

Copyright (C) 2007 Timotheus Keefer

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6 or,
at your option, any later version of Perl 5 you may have available.

=cut
